退出临界区时,引用数减1,当引用减为0时,删除被引用的ID记录。
static void winMutexLeave(sqlite3_mutex *p){
#ifndef NDEBUG
DWORD tid = GetCurrentThreadId();
assert( p->nRef>0 );
assert( p->owner==tid );
p->nRef--; //退出临界区时,引用数减1
if( p->nRef==0 ) p->owner = 0; //引用减为0时,删除被引用的ID记录
assert( p->nRef==0 || p->id==SQLITE_MUTEX_RECURSIVE );
#endif
LeaveCriticalSection(&p->mutex);
#ifdef SQLITE_DEBUG
if( p->trace ){
printf("leave mutex %p (%d) with nRef=%d\n", p, p->trace, p->nRef);
}
#endif
}